<?php
require_once dirname(__FILE__).'/model/common.inc.php';

define('DEDE_FILE','digest_doctor');

/*
总数<?php echo $askcount，每页 $tpp，页次$page/$tpp，  首页 | 上页 | 下页 | 尾页
*/
$doctorcount = $dsql->getone("select count(*) as dd from `#@__doctor`");
$tpp = 5;
$askcount = $doctorcount['dd'];
$realpages = @ceil($askcount/$tpp);
if($page > $realpages)
{
	$page = $realpages;
}
$page = isset($page) ? max(1, intval($page)) : 1;
$start_limit = ($page - 1) * $tpp;

$multipage = multiy($askcount,$realpages,$tpp,$page,'digest_doctor.php?');
$sql = "Select * from `#@__doctor` where station =1 limit $start_limit, $tpp";
$dsql->Execute('me',$sql);
while($row = $dsql->getarray())
{
	$professions[] = $row[professions];
	$row[description] = cn_substr(strip_tags($row[description],''),300);
	$doctors[] = $row;
}
$professions[] = 0;
$in = implode(',',$professions);
$sql = "select * from `#@__ask` where tid in($in) or tid2 in($in) limit 0,10";
$dsql->Execute('me',$sql);
while($ask = $dsql->getarray())
{
	$asks[] = $ask;
}
$dtp = new DedeTemplate();
$dtp->LoadTemplate(ASKROOT.'/template/default/digestdoctor.htm');

if($cfg_ask_rewrite=='Y')
{
	$dtp->Display();
	myecho();
	exit();
}
else
{
	$dtp->Display();
}
?>